package com.leetcode.LC;

public class LC392 {
    //双指针
    public boolean isSubsequence(String s, String t) {

        if (s.length()==0){
            return true;
        }else if(s.length()!=0&&t.length()==0){
            return false;
        }else if(s.length()==0&&t.length()==0){
            return true;
        }

        int a = 0, b = 0;
        while (b < t.length()) {
            if (s.charAt(a) == t.charAt(b)) {
                a++;
                if (a == s.length()) {
                    return true;
                }
                b++;
            } else if (s.charAt(a) != t.charAt(b)) {
                b++;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new LC392().isSubsequence("abc", "ahbgdc"));
    }
}
